package com.footprint.quartz;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.footprint.main.ThreadPoolManager;
import com.footprint.quartz.callable.AirChinaCallable;

/**
 * 所有网站的轮询，多线程实现
 * @author lsj
 *
 */
public class AllScan{
	private static final Log log = LogFactory.getLog(AllScan.class);

    public AllScan() {
    }

    public void scan() {
    	startScan();
    }

    public void startScan() {
    	/** 开始多线程检查 **/
        long startTime = System.currentTimeMillis();
        log.info("all scan start ...");
        
        List<Callable<String>> works = new ArrayList<Callable<String>>();
        Callable<String> airChina = new AirChinaCallable();
        works.add(airChina);

        try {
            ThreadPoolManager.getInstance().getThreadPoolExecutor().invokeAll(works);
            works = null;
        } catch (InterruptedException ex) {
            Logger.getLogger(AllScan.class.getName()).log(Level.SEVERE, null, ex);
        }
        long endTime = System.currentTimeMillis();
        log.info("all scan stop  (using time is " + (endTime - startTime) / 1000.0 + "s)");
    }
}
